package net.cn_su.sharpeyes.application;

import android.app.Application;

import com.hik.mcrsdk.MCRSDK;
import com.hik.mcrsdk.rtsp.RtspClient;
import com.hik.mcrsdk.talk.TalkClientSDK;
import com.hikvision.vmsnetsdk.ServInfo;

import net.cn_su.sharpeyes.beans.Organization;

import org.androidannotations.annotations.EApplication;

import java.util.List;

/**
 * Created by Overlord on 2016/08/15.
 */
@EApplication
public class SuApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        System.loadLibrary("gnustl_shared");
        MCRSDK.init();
        RtspClient.initLib();
        MCRSDK.setPrint(1, null);
        TalkClientSDK.initLib();
     /*   Logger.init("result")               // default tag : PRETTYLOGGER or use just init()
                .setMethodCount(3)            // default 2
                .hideThreadInfo()             // default it is shown
                .setLogLevel(LogLevel.FULL);  // default : LogLevel.FULL*/
    }

    /**
     * 服务器登录返回的数据
     */
    private ServInfo servInfo;

    /**
     * 能查看的组织结构
     */
    private List<Organization> organizations;

    public List<Organization> getOrganizations() {
        return organizations;
    }

    public void setOrganizations(List<Organization> orgs) {
        this.organizations = orgs;
    }

    /**
     * 第一个村
     */
    public int getOrgFirstId(){

        for(Organization item : organizations){
            if (item.getOrg_type() !=0){
                return item.getId();
            }
        }
        return -1;
    }

    /**
     * 通过ID获取机构对象
     *
     * @param id 机构ID
     * @return 机构对象
     */
    public Organization getOrgById(int id) {
        Organization org = null;
        for (Organization item : organizations) {
            if (item.getId() == id) {
                org = item;
                break;
            }
        }
        return org;
    }

    public ServInfo getServInfo() {
        return servInfo;
    }

    public void setServInfo(ServInfo servInfo) {
        this.servInfo = servInfo;
    }
}
